using System;
using System.Reflection;

namespace MULENetworking
{

	// What's this???
	// We need a way for clients to submit delegates (which are methods to handle events) 
	// to the Manager object.
	// To do this, we require our clients to derive this class 
	// and override the OurInternalCallback 
	// (that's why we declared the class abstract and the method abstract - 
	// so anyone wanting to use this class ain't going to compile without implementing it

	// What is OurInternalCallback?
	// This is where our clients tell themselves how to handle the event
	// Therefore, by this below, we would have achieved our goal,
	// which is to force our clients to use the OurMethodCallback function in their remotable delegates. 
	// Once again, remember, this is implemented on the client!
	public abstract class RemotelyDelegatableObject : MarshalByRefObject
	{
		public void OurMethodCallback (object sender, Manager.SubmitEventArgs submitArgs)
		{
			OurInternalCallback (sender, submitArgs) ;		
			// This OurInternalCallback method will call our concrete implementation
			// of OurInternalCallback (don't be confused below, abstract void OurInternalCallback
			// is an abstract method! 
		}

		protected abstract void OurInternalCallback (object sender, Manager.SubmitEventArgs submitArgs) ;
	}

	// Reflections (not .Net's reflections! Just Simple english)...
	// QUESTION: Why is our RemotelyDelegatableObject so complicated??
	// The abstract class needs to have a specific structure. Notice:
	// 1. The function to be used for callbacks must be a public function that cannot be overriden 
	// (ie. protected sealed override void OurInternalCallback)
	// 2. OurMethodCallback must forward all calls to a protected abstract function (OurInternalCallback)
	// that is overridden in the derived client classes (protected override void OurInternalCallback, Client.cs/vb)

}
